package org.devf.fork.imsimulator.socket.dto;

import cn.hutool.core.util.IdUtil;
import org.devf.fork.imsimulator.model.DevConstant;
import org.devf.fork.imsimulator.model.UserModel;

import java.util.HashMap;
import java.util.Map;

/**
 * ConnectPackets related
 *
 * @author wanghuafu
 * @since 0.1 2023/9/12
 */
public class ConnectPackets extends BasePackets{

    public ConnectPackets() {
        super();
    }

    public static ConnectPackets build(UserModel loginUser,String token){
        ConnectPackets basePackets = new ConnectPackets();
        basePackets.setId(IdUtil.getSnowflakeNextId());
        basePackets.setPackageId(String.valueOf(IdUtil.getSnowflakeNextId()));
        basePackets.setAck(false);
        basePackets.setBizType(BizType.CONNECT.name());
        basePackets.setIsNeedAck(1);
        basePackets.setFromDeviceId(loginUser.getDeviceId());
        Map<String,String> content = new HashMap<>();
        content.put("token",token);
        basePackets.setContents(content);
        return basePackets;
    }
}
